package com.sunyard.manage.controller;

import com.sunyard.constant.ErrMessageConst;
import com.sunyard.dal.bo.device.key.KeyWarningQueryBO;
import com.sunyard.dal.bo.device.lock.LockWarningQueryBO;
import com.sunyard.dal.bo.PaginationBO;
import com.sunyard.dal.bo.device.TerminalWarningQueryBO;
import com.sunyard.dal.dto.KeyWarningQueryDTO;
import com.sunyard.dal.dto.LockWarningQueryDTO;
import com.sunyard.dal.dto.TerminalWarningQueryDTO;
import com.sunyard.manage.service.TerminalWarningService;
import com.sunyard.utils.Response.BaseResult;
import com.sunyard.utils.Response.GetResult;
import com.sunyard.utils.manage.DataGrid;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wxl
 * @date 2022-07-06 15:25
 */
@Slf4j
@RestController
@RequestMapping(value = "/terminalWaring", method = RequestMethod.POST)
@Api(tags = "TerminalWarningController", description = "设备预警")
public class TerminalWarningController {

    @Autowired
    TerminalWarningService terminalWarningService;

    /**
     * @Description: PC端管理平台预警统计-设备预警
     * @author wxl
     * @date 2022年7月6日
     */
    @ResponseBody
    @ApiOperation("终端预警查询")
    @RequestMapping(value = "/queryTerminalWarning", method = RequestMethod.POST)
    public BaseResult<DataGrid<TerminalWarningQueryDTO>> queryTerminalWarning(
            @RequestBody PaginationBO<TerminalWarningQueryBO> queryBO, HttpServletRequest request) {
        try {
            return terminalWarningService.queryTerminalWarning(queryBO, request);
        } catch (Exception e) {
            log.error(ErrMessageConst.SYSTEM_ERROR, e);
            return GetResult.getResultErr();
        }
    }

    /**
     * @Description: PC端管理平台预警统计-设备预警-终端预警查询
     * @author wxl
     * @date 2022年7月6日
     */
    //@ResponseBody
    //@ApiOperation("终端预警查询")
    //@RequestMapping(value = "/queryKeyWarning", method = RequestMethod.POST)
    public BaseResult<DataGrid<KeyWarningQueryDTO>> queryKeyWarning(@RequestBody PaginationBO<KeyWarningQueryBO> queryBO, HttpServletRequest request) {
        try {
            return terminalWarningService.queryKeyWarning(queryBO, request);
        } catch (Exception e) {
            log.error(ErrMessageConst.SYSTEM_ERROR, e);
            return GetResult.getResultErr();
        }
    }

    /**
     * @Description: PC端管理平台预警统计-设备预警-锁具预警查询
     * @author wxl
     * @date 2022年7月11日
     */
    //@ResponseBody
    //@ApiOperation("锁具预警查询")
    //@RequestMapping(value = "/queryLockWarning", method = RequestMethod.POST)
    public BaseResult<DataGrid<LockWarningQueryDTO>> queryLockWarning(@RequestBody PaginationBO<LockWarningQueryBO> queryBO, HttpServletRequest request) {
        try {
            return terminalWarningService.queryLockWarning(queryBO, request);
        } catch (Exception e) {
            log.error(ErrMessageConst.SYSTEM_ERROR, e);
            return GetResult.getResultErr();
        }
    }

    /**
     * @Description: PC端管理平台预警统计-设备预警-尾箱预警查询 预留
     * @author wxl
     * @date 2022年7月6日
     */
    /*@ResponseBody
    @ApiOperation("尾箱预警查询")
    @RequestMapping(value = "/queryTailBoxWarning", method = RequestMethod.POST)
    public BaseResult<DataGrid<OperatorLog>> queryTailBoxWarning(@RequestBody PaginationBO<NonWorkTimeQueryBo> queryBO) {
        try {
            return terminalWarningService.queryTailBoxWarning(queryBO);
        } catch (Exception e) {
            log.error(ErrMessageConst.SYSTEM_ERROR, e);
            return GetResult.getResultErr();
        }
    }*/
}
